package com.beteng.su.betengsu.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;

/**
 * Created by chenzhimin on 2017/9/5.
 */

public class CommonUtils {
    public interface Method {

        String LOGIN = "Login";
        String GetOrderList = "GetOrderList";
        String Sign = "Sign";
        String Defect = "Defect";
        String GetWaybillTrace = "GetWaybillTrace";
        String WaybillTrace = "WaybillTrace";
        String UpdateArea = "UpdateArea";
        String Version = "Version";
    }

    /**
     * 共享参数名
     */
    private static  final String SHARED_NAME="betengapp";

    /**
     * 第一次保存的key值
     */
    private static  final String FIRST_RUN = "isFirstRun";

    public static boolean isFirstRun(Context context){
        SharedPreferences preferences=context.getSharedPreferences(SHARED_NAME,Context.MODE_PRIVATE);
        return preferences.getBoolean(FIRST_RUN,true);
    }

    /**
     * 进入主界面
     */
    public static void saveFirstRun(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE);
        preferences.edit().putBoolean(FIRST_RUN, false).apply();
    }

    /**
     * 配置recycleview
     *
     * @param recyclerView
     * @param layoutManager
     */
    public static void configRecycleView(final RecyclerView recyclerView
            , RecyclerView.LayoutManager layoutManager) {
        recyclerView.setLayoutManager(layoutManager);
        //如果可以确定每个item的高度是固定的，设置这个选项可以提高性能
        recyclerView.setHasFixedSize(true);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

}
